<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
</head>
<body>
    <h1>首页</h1>
    <form th:action="@{/testRequestBody}" method="post">
        <input type="text" name="username">
        <input type="text" name="password">
        <input type="submit" value="测试@RequestBody">
    </form>
    <form th:action="@{/testRequestEntity}" method="post">
        <input type="text" name="username">
        <input type="text" name="password">
        <input type="submit" value="测试@testRequestEntity">
    </form>
    <a th:href="@{/testResponse}">通过servletAPI的response对象相应浏览器数据</a>
    <a th:href="@{/testResponseBody}">通过@ResponseBody对象相应浏览器数据</a>
    <a th:href="@{/testResponseUser}">通过testResponseUser对象相应浏览器User对象</a>
    <div id="app">
        <a @click="testAxios" th:href="@{/testAxios}">SpringMVC处理ajax</a>
    </div>
    <script th:src="@{/static/js/vue.js}"></script>
    <script th:src="@{/static/js/axios.min.js}"></script>
    <script>
        new Vue({
            el:"#app",
            methods : {
                testAxios:function (event) {
                    axios({
                        method:"post",
                        url:event.target.href,
                        params:{
                            username:"admin",
                            password: "123456"
                        }
                    }).then(function (response) {
                        alert(response.data)
                    })
                    event.preventDefault();
                }
            }
        })
    </script>
</body>
</html>